package org.erp.procurement.enums;

import lombok.Getter;

/**
 * 订单支付状态
 *
 * @author libin
 * @version 1.0
 * @description: 订单支付状态
 * @date 2025/11/6 10:50
 **/
@Getter
public enum PaymentStatusEnum {

    TO_BE_PAID(0, "待打款"),
    SUCCESS(1, "打款成功"),
    FAILED(2, "打款失败");
    private final Integer code;
    private final String message;

    PaymentStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Integer getCodeByMessage(String message) {
        for (PaymentStatusEnum item : PaymentStatusEnum.values()) {
            if (item.getMessage().equals(message)) {
                return item.getCode();
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        for (PaymentStatusEnum item : PaymentStatusEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getMessage();
            }
        }
        return null;
    }

    public static PaymentStatusEnum getByCode(Integer code) {
        for (PaymentStatusEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static PaymentStatusEnum getByMessage(String message) {
        for (PaymentStatusEnum value : values()) {
            if (value.getMessage().equals(message)) {
                return value;
            }
        }
        return null;
    }

}
